<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var s = "13579";

    function string2int(s) {
        var nums =[];
        for(var i=0;i<s.length;i++)
        {
            nums[i] = s[i];
        }
        nums = nums.map(function(x){
            return x*1;

        })
        var num = nums.reduce(function(x,y){
            return x*10+y;
        })
        return num;
    }
    console.log(string2int(s));
</script>

</html>